<link rel="stylesheet" href="ccay/example/demo.css"  type="text/css" />
<script type="text/javascript" src="ccay/example/functionDemo/excel/demoImport.js" charset="utf-8"></script>
<style type="text/css">
.showClew{font-size: 12px; color: olive;}
.showClew span{color: peru;}
.spanShow{color: peru;}
</style>
<div id="demoImport">
<div title="Demo"  tabid='tab2'>
<form id="demoImportForm" class="init ccay-form">
	      <!--条件按钮区域-->
	      <div class="ccay-operate">
	 		<span id="btnSearch" class="default ccay-button">
	 			<a class="ccay-icon search"></a>
	 			<label class="i18n" i18nkey="ccay.common.button.search"></label>
	 		</span>
		  </div>
	</form>
<h4><span>实例：导入</span></h4>
<h5><span>动态列</span></h5>
<div style="margin-bottom: 10px;">
<input id="dynamic_chk_id_0" name="dynamic_chk_name" style="vertical-align:middle;" type='checkbox' value="value"/><label for="dynamic_chk_id_0">value<label>
<input id="dynamic_chk_id_1" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeOne"/><label for="dynamic_chk_id_1">attr1<label>
<input id="dynamic_chk_id_2" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeTwo"/><label for="dynamic_chk_id_2">attr2<label>
<input id="dynamic_chk_id_3" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeThree"/><label for="dynamic_chk_id_3">attr3<label>
<input id="dynamic_chk_id_4" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeFour"/><label for="dynamic_chk_id_4">attr4<label>
<input id="dynamic_chk_id_5" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeFive"/><label for="dynamic_chk_id_5">attr5<label>
<input id="dynamic_chk_id_6" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeSix"/><label for="dynamic_chk_id_6">attr6<label>
<input id="dynamic_chk_id_7" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeSeven"/><label for="dynamic_chk_id_7">attr7<label> 
<input id="dynamic_chk_id_8" name="dynamic_chk_name" style="vertical-align:middle;" type='checkbox' value="attributeEight"/><label for="dynamic_chk_id_8">attr8<label> 
<input id="dynamic_chk_id_9" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeNine"/><label for="dynamic_chk_id_9">attr9<label>
<input id="dynamic_chk_id_10" name="dynamic_chk_name"  style="vertical-align:middle;" type='checkbox' value="attributeTen"/><label for="dynamic_chk_id_10">attr10<label>
</div> 
<div>
<div style="margin-bottom: 10px;">
<label>导出文件名成的动态参数（不要输入特殊字符 没做验证）<label><input maxlength="10" id="dynamic_p_id" name="dynamic_p_name" style="vertical-align:middle;" type='text' value=""/>
<label>导入错误回写<label><select id="dynamic_error_id" name="dynamic_error_name">
<option value="txt" selected="selected">文本回写</option>
<option value="allxlsx" >所有数据回写到excel</option>
<option value="errorxlsx" >只回写错误的数据到excel</option>
</select>
<div>
	<!--grid操作区域-->
	<div class="ccay-grid">
	 <div class="ccay-grid-toolbar">
	 	<span class="ccay-button hasPermission" ccayPermission="Service$IDemoImprot.Manage$import" onclick="Ccay.example.functionDemo.excel.DemoImport(this)">
	 		<a class="ccay-icon import"></a>
	 		<label class="i18n" i18nKey="ccay.common.button.import"></label>
	 	</span>
	 	<span class="ccay-button hasPermission" ccayPermission="Service$IDemoImprot.Manage$import" onclick="Ccay.example.functionDemo.excel.DemoSyncImport(this)">
	 		<a class="ccay-icon import"></a>
	 		<label class="i18n" i18nKey="ccay.common.button.syncimport"></label>
	 	</span>
	 	<span class="ccay-button hasPermission" ccayPermission="Service$IDemoExport.Manage$export" onclick="Ccay.example.functionDemo.excel.demoExport(this)">
	 		<a class="ccay-icon export"></a>
	 		<label class="i18n" i18nKey="ccay.common.button.export"></label>
	 	</span>
	 	<span class="ccay-button hasPermission" ccayPermission="Service$IDemoExport.Manage$export" onclick="Ccay.example.functionDemo.excel.griddemoExport(this)">
	 		<a class="ccay-icon export"></a>
	 		<label>导出显示列数据</label>
	 	</span>
	 	<span class="ccay-button hasPermission" ccayPermission="Service$IDemoExport.Manage$export" onclick="Ccay.example.functionDemo.excel.resultSetExport(this)">
	 		<a class="ccay-icon export"></a>
	 		<label>ResultSet(数据集合方式) Export</label>
	 	</span>
	 	<span class="ccay-button hasPermission" ccayPermission="Service$IDemoExport.Manage$export" onclick="Ccay.example.functionDemo.excel.resultIexcelExport(this)">
	 		<a class="ccay-icon export"></a>
	 		<label>Iexcel Export</label>
	 	</span><br>
 		<a onclick="Ccay.example.functionDemo.excel.demoExcelTemplate()" i18nKey="导入模板下载" class="init i18n hasPermission" ccayPermission="Service$IDemoImprot.Manage$import"></a>
 		<a href="servlet/download?dlType=ExcelTemplate&excelType=ccay.exampleSync" i18nKey="同步模板下载" class="init i18n hasPermission" ccayPermission="Service$IDemoImprot.Manage$import"></a>
 		<a  onclick="Ccay.example.functionDemo.excel.demoDynamicExcelTemplate()"  i18nKey="动态模板下载" class="init i18n hasPermission" ccayPermission="Service$IDemoImprot.Manage$import"></a>
	 </div>
	 <!--数据表格-->
	 <div id="demoImportGrid"></div>
	 <div id="demoSyncImportData"></div>
	</div>
	<div style="float: left;">
		<span>备注：该Demo只展示界面样式，以及所具有的功能。首先下载模板,填充数据后再执行导入操作</span>
	</div>
</div>
</div>
<div title="功能描述" tabid='tab3'><br>
<h4><span>----------导入----------</span></h4><br>
		<h3>html 源码:</h3>
		<div class="codeArea">
			<pre id='html1'>
&lt;input type="button" onclick="Ccay.example.demoImport.DemoImport(this)" 
i18nKey="ccay.common.button.import" class="init i18n hasPermission" 
ccayPermission="Service$IDemoImprot.Manage$import" >
			</pre>
		</div>
		<h3>js 源码:</h3>
		<div class="codeArea">
			<pre id='js1'>
page.DemoImport = function() {
	var param = {
		uploadType : "ExcelImport",
		completeCallback : Ccay.Component.Excel.uploadCallback,
		closeDialog : true,
		query : "excelType=ccay.example",
		maxFileCount : 1
	};
Ccay.Component.openUploadDialog("Demo Import", param);
}
			</pre>
		</div>

<h4><span>----------导出----------</span></h4><br>
		<h3>html 源码:</h3>
		<div class="codeArea">
			<pre id='html2'>
&lt;input onclick="Ccay.example.demoImport.demoExport(this)" class="init i18n hasPermission"
ccayPermission="Service$IDemoExport.Manage$export" 
i18nKey="ccay.common.button.export" type="button">
			</pre>
		</div>
		<h3>js 源码:</h3>
		<div class="codeArea">
			<pre id='js2'>
page.demoExport = function() {
	if (!$S("#demoImportForm").valid())
	return;
	Ccay.doGet("services/ccay/example/demoExport/list/export",
	$S("#demoImportForm").jsonData(), function() {
	Ccay.Component.Excel.exportCallback();
	});
}
			</pre>
		</div>

<h4><span>----------添加错误信息----------</span></h4><br>
		<h3>手动添加错误信息</h3>
		<div class="codeArea">
			<pre id='java1'>
//方法类    fail  end方法中都行
List<ExcelCellError> cellErrorList=new ArrayList<ExcelCellError>();//创建excel错误信息
cellErrorList.add(new ExcelCellError("zh", 1, "1", "错误"));  //添加错误信息
context.addCellErrors(cellErrorList);//增加excel错误信息
			</pre>
		</div>
		
		<h3>查询添加错误信息</h3>
		<div class="codeArea">
			<pre id='java2'>
@Inject
private IImportTaskService importTaskService; //导入消费类申明
   
   //方法类    fail  end方法中都行
List<ExcelCellError> cellErrorList=new ArrayList<ExcelCellError>();//创建excel错误信息
ImportErrorsVO importErrorsVO=new ImportErrorsVO();
importErrorsVO.setTaskId(context.getRequest().getTaskId());//设置taskId
//根据taskId查询错误信息
List<ImportErrorsVO> importcellErrorList=importTaskService.findImportErrorsList(importErrorsVO);
for(int i=0;i&lt;importcellErrorList.size();i++){
ImportErrorsVO errorsVO=importcellErrorList.get(i);
cellErrorList.add(new ExcelCellError(errorsVO.getSheetName(), errorsVO.getRowno(),"", errorsVO.getErrorMessage()));
}
context.addCellErrors(cellErrorList);//增加excel错误信息
			</pre>
		</div>
		
		<span>导入begin方法：主要用于导入前的操作，例如：纪录日记、初始化变量等；fail跟end方法：主要用于添加错误信息</span>
</div>
</div>
</div>
<div title="自定义列导出" tid="tab5">
<span class="showClew">备注：该Demo只展示界面样式，以及所具有的功能，***自定义列数据可从个性化设置中设置隐藏或显示***</span><br /><br />
<div>
	<!--grid操作区域-->
	<div class="ccay-grid">
	 <div class="ccay-grid-toolbar">
	 	
	 	<span class="ccay-button hasPermission" ccayPermission="Service$IDemoExport.Manage$export" onclick="Ccay.example.functionDemo.excel.igriddemoExport(this)">
	 		<a class="ccay-icon export"></a>
	 		<label>导出自定义列数据</label>
	 	</span>
	 	<span></span>
	 </div>
	 <!--数据表格-->
	 <div id="demoImportGrid1"></div>
	</div>
	<div style="float: left;">
		<span></span>
	</div>
</div>
<br><h4><span>----------导出----------</span></h4>
		<h3>html 源码:</h3>
		<div class="codeArea">
			<pre id='html2'>
&lt;input onclick="Ccay.example.demoImport.igriddemoExport(this)" class="init i18n hasPermission"
ccayPermission="Service$IDemoExport.Manage$export" 
i18nKey="ccay.common.button.export" type="button">
			</pre>
		</div>
		<h3>js 源码:</h3>
		<div class="codeArea">
			<pre id='js2'>
/**
 * 获取igrid显示列的数据
 */
igridcolumndatas = function() {
	var igrid = $("#demoImportGrid1").manager();
	var hList = [];
	$.each(igrid.op.columns, function(i, c) {
	// 把igird显示列信息加入 hList
		(c.hidden == undefined || !c.hidden)
						&& hList.push(c);
		})

			var data = {};
		    for (var i = 0; i &lt; hList.length; i++) {
				// 把要导出的列属性设定一个默认的值1,json然后放到data{};
					data[hList[i].field] = '1';
				}
					return data;
			}
page.igriddemoExport = function() {
	Ccay.doGet("services/ccay/example/demoExport/dynamiclist/export",
						igridcolumndatas(), function() {
							Ccay.Component.Excel.exportCallback();
				});
	}
			</pre>
		</div>
</div>